package main

type State interface {
	Switch(context *Context)
}

// Context 记录当前得状态
type Context struct {
	state State
}

func (c *Context) SetState(state State) {
	c.state = state
}
func (c *Context) Switch() {
	c.state.Switch(c)
}

type OnState struct {
}

func (c *OnState) Switch(context *Context) {
	context.SetState(&OffState{})
}

type OffState struct {
}

func (c *OffState) Switch(context *Context) {
	context.SetState(&OnState{})
}

func main() {

}
